apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: ${NAME_SPACE}
  labels:
    app: ${APP_NAME}
  name: ${APP_NAME}-deployment
spec:
  replicas: ${REPLICAS}
  revisionHistoryLimit: 10
  strategy:
    type: RollingUpdate
    rollingUpdate:
            maxSurge: 1
            maxUnavailable: 0
  selector:
    matchLabels:
      app: ${APP_NAME}
  template:
    metadata:
      labels:
        app:  ${APP_NAME}
    spec:
      imagePullSecrets:
      - name: ${IMAGE_PULL_SECRETS}	
      containers:
      - image: ${IMAGE_URL}/${IMAGE_TAG}
        name: ${APP_NAME}
        imagePullPolicy: Always
        ports:
        - containerPort: ${PORTS}
        env:
        - name: aliyun_logs_${APP_NAME}
          value: "stdout"
        - name: aliyun_logs_${APP_NAME}_tags
          value: "app=${APP_NAME},env=${VERSION}"
        - name: aliyun_logs_${APP_NAME}-info
          value: "/logs/INFO.*.log"
        - name: aliyun_logs_${APP_NAME}-info_tags
          value: "app=${APP_NAME},env=${VERSION}"
        - name: aliyun_logs_${APP_NAME}-error
          value: "/logs/ERROR.*.log"
        - name: aliyun_logs_${APP_NAME}-error_tags
          value: "app=${APP_NAME},env=${VERSION}"
        # 容器内文件日志路径需要配置emptyDir
        - name: JAVA_OPTS
          value: "${JAVA_OPTS}"
        - name: APOLLO_META
          value: "${APOLLO_META}"
        - name: APP_ID
          value: "${APP_ID}"
        - name: XXL_IP
          value: "${XXL_IP}"
        - name: XXL_PORT
          value: "${XXL_PORT}"
        volumeMounts:
        - name: host-time
          mountPath: /etc/localtime
        - name: app-log
          mountPath: /logs
      volumes:
        - name: host-time
          hostPath:
            path: /etc/localtime
        - name: app-log
          emptyDir: {}

---
apiVersion: v1
kind: Service
metadata:
  namespace: ${NAME_SPACE}
  labels:
  name: ${APP_NAME}-svc
spec:
  selector:
    app: ${APP_NAME}
  ports:
  - port: ${NODE_PORT}
    protocol: TCP
    targetPort: ${PORTS}

---
apiVersion: v1
kind: Service
metadata:
  namespace: ${NAME_SPACE}
  labels:
  name: ${APP_NAME}-xxl-svc
spec:
  type: NodePort
  selector:
    app: ${APP_NAME}
  ports:
  - port: ${XXL_PORT}
    protocol: TCP
    targetPort: ${XXL_PORT}
    nodePort: ${XXL_PORT}